import groovy.xml.MarkupBuilder

class Example{

    static void main(String[] args){
        def mb = new MarkupBuilder()

        // 生成xml <collection><movie/><type/><format/>..</collection>
        mb.collection(shelf: 'New Arrivals'){
            movie(title: 'Enemy Behind')
            type('War, Thriller')
            format('DVD')
            year('2003')
            rating('PG'){  // 可以随便扩展元素
                lee(12)
                dralee(32)
            }
            starts(10)
            description('Talk about a US-Japan war')
        }
    }

}